//1 .导入express模块
const express = require('express');
const urllib = require('url')
const app = express();


//get请求
app.get('/user', function (req, res) {
    var params = urllib.parse(req.url, true);
    //向客户端发送数据
    let a = {
        "status": 200,
        "msg": "获取图书列表成功",
        "data": [
            {
                "id": 1,
                "bookname": "西游记",
                "author": "吴承恩",
                "publisher": "北京图书出版社"
            },
            {
                "id": 2,
                "bookname": "红楼梦",
                "author": "曹雪芹",
                "publisher": "上海图书出版社"
            },
            {
                "id": 3,
                "bookname": "三国演义",
                "author": "罗贯中",
                "publisher": "北京图书出版社"
            },
            {
                "id": 35,
                "bookname": "天天向上",
                "author": "嘎",
                "publisher": "嘎嘎"
            },
            {
                "id": 31,
                "bookname": "加油",
                "author": "努力",
                "publisher": "出版社"
            },
            {
                "id": 29,
                "bookname": "西游记史记",
                "author": "司马迁",
                "publisher": "上海图书出版社"
            },
            {
                "id": 34,
                "bookname": "水浒传",
                "author": "施耐庵",
                "publisher": "北京图书出版社"
            }
        ]
    };
    res.send(params.query.callback + '(' + JSON.stringify(a) + ')')
})
app.listen(89, () => {
    console.log('http://127.0.0.1:89');

})